﻿/*Just a little warning here, this is based off of some*
 * rather nasty hacks. Read at your own risk.          *
 * all is commented out because it's broken from compi-*
 * ler bugs which result in every instruction being    *
 * repeated :( What a pain in the ass                  *
 * *****************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.Assembler;
using Cosmos.IL2CPU.Plugs;

namespace CosmosKernel4.Plugs
{
    [Plug(Target = typeof(CosmosKernel4.Global.Bex))]   
    static class BinaryExecuter
    {
        [PlugMethod(Assembler = typeof(ExecImpl))]
        public static void execute(byte[] pointer) { }
    }
    public class ExecImpl : AssemblerMethod
    {
        public override void AssembleNew(object aAssembler, object aMethodInfo)
        {
            Cosmos.Assembler.Assembler Assembler = (Cosmos.Assembler.Assembler)aAssembler;
            Assembler.Add(new LiteralAssemblerCode("mov .old_eax, eax"));//Move eax to old_eax
            Assembler.Add(new LiteralAssemblerCode("pop eax"));
 *          Assembler.Add(new LiteralAssemblerCode("mov .addr, eax"));
 *          Assembler.Add(new LiteralAssemblerCode("mov eax, .old_eax"));
 *          Assembler.Add(new LiteralAssemblerCode("pushad");
 *          
            Assembler.Add(new LiteralAssemblerCode("call eax"));
            
            Assembler.Add(new LiteralAssemblerCode("popad"));
            Assembler.Add(new LiteralAssemblerCode("ret")); //Done! Don't want them going through the data below, so just have a ret here
            Assembler.Add(new LiteralAssemblerCode(".old_eax dd 0"));
            Assembler.Add(new LiteralAssemblerCode(".addr dd 0"));
            
        }
            
       


    }
}
*/